package com.yunhe.portal.client;


import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.MessageCenter;
import com.yunhe.common.model.authority.User;
import com.yunhe.common.model.base.MessageReadCount;
import com.yunhe.common.model.company.Company;
import com.yunhe.portal.client.fallback.AuthorityFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * @Author: DongWenYu
 * @Date: 2021/2/23 14:26
 */
@ApiIgnore
@FeignClient(value = "yh-authority", fallbackFactory = AuthorityFallbackFactory.class)
@Component
public interface AuthorityClient {

    @GetMapping(value = "/users/findStationUserByStationId")
    ResponseEntity<ResultObject<List<User>>> findStationUserByStationId(@RequestParam(value = "stationId",required = true) Long stationId);

    @PostMapping("/messageCenter/batchCreateMessageCenter")
    ResponseEntity<ResultObject<Iterable<MessageCenter>>> batchCreateMessageCenter(@RequestBody List<MessageCenter> dataLists);

    @GetMapping(value = "/companys/findCompanyByRealStationId")
    ResponseEntity<ResultObject<List<Company>>> findCompanyByRealStationId(@RequestParam(value = "stationId",required = true) Long stationId);

    /**
     * 查询真实园区（携带厂房）
     * @param stationId 总园区ID
     */
    @RequestMapping(value = "/realStation/searchStationAndOfficeByStationId/{stationId}", method = RequestMethod.GET)
    ResponseEntity<ResultObject> searchStationAndOfficeByStationId(@PathVariable("stationId") Long stationId);

    @RequestMapping(value = "/messageCenter/getMessageCountByCondition", method = RequestMethod.GET)
    ResponseEntity<ResultObject<MessageReadCount>> getMessageCountByCondition(@RequestParam(value = "businessId",required = true) Long businessId,
                                                                              @RequestParam(value = "messageType",required = true) String messageType);

    /************消息推送***************/

    /**
     * 根据用户Ids推送消息
     * @param userIds 用户Ids
     * @param notificationTitle 通知标题
     * @param msgContent 消息内容
     * @param extras 额外字段
     * @return ResponseEntity<ResultObject>
     */
    @RequestMapping(value = "/appPush/pushMessageByUserIds", method = RequestMethod.POST)
    ResponseEntity<ResultObject> pushMessageByUserIds(@RequestParam("userIds") String userIds,
                                                             @RequestParam("notificationTitle") String notificationTitle,
                                                             @RequestParam("msgContent") String msgContent,
                                                             @RequestBody() Map<String, String> extras);

    /**
     * 根据虚拟园区id推送消息
     * @param stationId 虚拟园区ID
     * @param notificationTitle 通知标题
     * @param msgContent 消息内容
     * @param extras 额外字段
     * @return ResponseEntity<ResultObject>
     */
    @RequestMapping(value = "/appPush/pushMessageByStationId", method = RequestMethod.POST)
    ResponseEntity<ResultObject> pushMessageByStationId(@RequestParam("stationId") Long stationId,
                                                               @RequestParam("notificationTitle") String notificationTitle,
                                                               @RequestParam("msgContent") String msgContent,
                                                               @RequestBody() Map<String, String> extras);
}
